package com.da.web.sys_role_menu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.da.web.sys_role_menu.entity.SysRoleMenu;
import com.da.web.sys_role_menu.mapper.SysRoleMenuMapper;
import com.da.web.sys_role_menu.service.SysRoleMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author da
 * @time 2023/12/3 下午 12:20
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {

    @Override
    public void saveRoleMenu(Long roleId, List<Long> menuIds) {
        //先删除角色原来的id,再重新插入
        QueryWrapper<SysRoleMenu> query = new QueryWrapper<>();
        query.lambda().eq(SysRoleMenu::getRoleId, roleId);
        this.baseMapper.delete(query);
        this.baseMapper.saveRoleMenu(roleId, menuIds);
    }
}
